import axios from 'axios'
// axios.defaults.baseURL = 'http://houtai.bendibao.com/fankui/'

axios.defaults.timeout = 20000;
//接口请求拦截
// axios.interceptors.request.use(
//   config => {
//     let token = localStorage.getItem("token")
//     if (localStorage.getItem("token")) {
//       config.headers['token']= token;
//     }
//     return config
//   }
// )

export function get(url, params) {
  return new Promise((resolve, reject) => {
    axios.get(url, {
      params: params
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

export function post(url, data) {
  return new Promise((resolve, reject) => {
    axios.post(url, data,{headers:{
      "Content-Type": "application/json"
    }})
      .then(res => {
        resolve(res)
      })
      .catch(err => {
        reject(err)
      })
  })
}